package com.wushuu.ce.present;

import com.wushuu.ce.config.RequestParam;
import com.wushuu.ce.config.RequestUrl;
import com.wushuu.ce.http.HttpHelper;
import com.wushuu.ce.interfaces.IBasePresenter;
import com.wushuu.ce.interfaces.IBaseView;
import com.wushuu.ce.model.UserModel;
import com.wushuu.ce.utils.TransferUtils;

import org.xutils.http.HttpMethod;

import java.util.Map;

/**
 * ============================================================
 * <br/>
 * 作 者 :        xyb
 * <br/>
 * 版 本 :        1.0
 * <br/>
 * 创建日期 ：     2016-05-11 下午9:48
 * <br/>
 * 描 述 ：
 * <br/>
 * 修订历史 ：
 * <br/>
 * ============================================================
 **/
public class LoginPresent implements IBasePresenter {

    private IBaseView view;

    public LoginPresent(IBaseView view){
        this.view = view;
    }


    @Override
    public void request(int requestCode) {
        if(requestCode == RequestParam.REQUEST_LOGIN){
            UserModel userModel = (UserModel)view.getInfo(requestCode);
            Map paramMaps = TransferUtils.transBean2Map(userModel);
            new HttpHelper(this,requestCode).execute(RequestUrl.USER_LOGIN,paramMaps, HttpMethod.GET);
        }
    }

    @Override
    public void response(String data, int respondCode) {
        view.setInfo(data,respondCode);
    }
}
